package UIFree.controls
{
	import UIFree.components.uif_arrowflat;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	import UIFree.uif_transition;
	
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class uif_arrowButtonFlat extends uif_ecomponent {
		private var _arrow		: uif_arrowflat;
		private var _orientation: Number; 
		public function uif_arrowButtonFlat(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			var inner: Rectangle = getInner();
			_arrow = new uif_arrowflat(this, inner.x + inner.width / 2, inner.y + inner.height / 2, inner.size.length, 2, stParam('arrow'));
			_arrow.density = 0.5;
			orienation = 0;
			addEvent(MouseEvent.ROLL_OVER, doOver);
			addEvent(MouseEvent.ROLL_OUT, doOut);
			buttonMode = true;
		}
		
		protected function doOver(e: MouseEvent): void {
			_arrow.fx('density', _arrow.density, 1, uif_transition.easeInOut(uif_transition.Back, 3)).start();
		}
		
		protected function doOut(e: MouseEvent): void {
			_arrow.fx('density', _arrow.density, 0.5, uif_transition.easeInOut(uif_transition.Back, 3)).start();
		}
		
		public function get orienation(): Number {
			return _orientation;
		}

		public function set orienation(a_orienation: Number): void {
			_orientation = a_orienation;
			_arrow.rotation = _orientation * 90 - 135;
		}
	}
}